<template>
	<view>
		学生列表
		<ul>
			<li v-for="(item,index) in arr">
				{{item.name}}{{item.xuehao}}
			</li>
		</ul>
		<input type="text" v-model="nm" style="border: #007AFF solid 0.5rpx;"/>
		<button @click="go">添加</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				arr: [],
				nm: ""
			}
		},
		onLoad() {
			let that=this;
			uniCloud.callFunction({
				name: 'list',
				success(re){
					//alert(JSON.stringify(re.result));
					that.arr = re.result;
					//location.reload();
				}
			});
		},
		methods: {
			//添加
			go(){
				uniCloud.callFunction({
					name: 'add', //add云函数
					data: {
						stu:{name:this.nm}
					},
					success(re){
						//alert(JSON.stringify(re.result));
						location.reload();
					}
				});
			}
		}
	}
</script>

<style>

</style>
